package com.berwin.syncer.entity;

import com.alibaba.fastjson.JSONObject;

import java.io.File;

public class SharedFiles {

    private String sender;
    private String path;

    public SharedFiles(String sender, String path) {
        this.sender = sender;
        this.path = path;
    }

    public String getSender() {
        return sender;
    }

    public void setSender(String sender) {
        this.sender = sender;
    }

    public String getPath() {
        return path;
    }

    public void setPath(String path) {
        this.path = path;
    }

    public JSONObject toJSONObject() {
        JSONObject obj = new JSONObject();
        obj.put("sender", this.sender);
        obj.put("path", this.path);
        return obj;
    }

    public static SharedText parseFromJSONObject(JSONObject obj) {
        return new SharedText(obj.getString("sender"), obj.getString("path"));
    }

    public String getName() {
        return this.path.substring(this.path.lastIndexOf(File.separator) + 1);
    }
}
